#include <windows.h>
#include "defines.h"
#include "charInfo.h"

#pragma once

class Screen {

private:
	CharInfo m_default;

	CharInfo *m_buffer;

	CONSOLE_SCREEN_BUFFER_INFO m_info;
	HANDLE m_hScreen;

	COORD m_screenSize;
public:
	Screen();
	~Screen();

	bool init();

	void setColor( WORD a_color ) { m_default.Color = a_color; }
	void setBgChar( char a_char ) { m_default.Char = a_char; }
	void invertColor( int, int );

	void displayBuffer();
	COORD displayAt( int, int, char * );
	void setAt( int, int, char, WORD = COLOR_SCREEN );
	void setAt( int x, int y, CharInfo ch ) { setAt( x, y, ch.Char, ch.Color ); }

	void clearScreen();

	void clearBuffer();

	COORD *getBottomRight() { static COORD bottomRight = { SCREEN_SIZE_X - 1, SCREEN_SIZE_Y - 1 }; return &bottomRight; }
	int getBufferSize() { return SCREEN_SIZE_Y * SCREEN_SIZE_X; }

	int bufXY( int a_x, int a_y ) { return a_y*SCREEN_SIZE_X+a_x; }
};